package com.zhu.pre.mapper;

import com.sanploy.common.domain.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * Created by zhu yingzhi on 2017/9/21.
 * @author yingzhi zhu
 * 手机用户数据库操作实体类
 */
@Mapper
public interface MUserMapper {

    /**
     * 插入用户
     * @param user 用户实体
     * @return 数据库影响行数
     */
    int insertUser(User user);

    /**
     * 通过id查找用户
     * @param id 用户id
     * @return User实体
     */
    @Select("SELECT *,nick_name AS nickName,avatar_url AS avatarUrl FROM  users WHERE id=#{id}")
    User findUserById(@Param("id") Long id);

    /**
     * 通过openid 查找用户
     * @param openid openid
     * @return User实体
     */
    @Select("SELECT *,nick_name AS nickName,avatar_url AS avatarUrl FROM  users WHERE openid=#{openid}")
    User findUserByOpenid(@Param("openid") String openid);
}
